<template>
  <div>
    <el-form-item label="应急预案情况">
      <el-select v-model="value.mergencyStatus" :disabled="disabled" placeholder="请选择" class="input" @change="handleChange">
        <el-option
          v-for="dict in dict.type.env_content_status"
          :key="dict.value"
          :label="dict.label"
          :value="dict.value"
        />
      </el-select>
    </el-form-item>
    <template v-if="value.mergencyStatus === '有'">
      <el-form-item label="是否备案">
        <el-select v-model="value.mergencyRecordStatus" :disabled="disabled" placeholder="请选择" class="input" @change="handleChange">
          <el-option
            v-for="dict in dict.type.env_sys_basic_exist"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <template v-if="value.mergencyRecordStatus === '是'">
        <el-form-item label="备案时间">
          <el-date-picker
            v-model="value.mergencyRecordTime"
            :disabled="disabled"
            type="date"
            format="yyyy年MM月dd日"
            placeholder="选择时间"
            class="input"
            @change="handleChange"
          />
        </el-form-item>
        <el-form-item label="是否存在应急池">
          <el-select v-model="value.mergencyLagoonStatus" :disabled="disabled" placeholder="请选择" class="input" @change="handleChange">
            <el-option
              v-for="dict in dict.type.env_sys_basic_exist"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
      </template>
    </template>
  </div>
</template>
<script>
import { formatDatetime } from '@/utils'

export default {
  name: 'Emergency',
  dicts: ['env_content_status', 'env_sys_basic_exist'],
  props: {
    disabled: Boolean,
    value: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {

    }
  },
  methods: {
    handleChange() {
      if (this.value.mergencyRecordTime) this.value.mergencyRecordTime = formatDatetime(this.value.mergencyRecordTime, 'YYYY-MM-DDTHH:mm:ss')
      this.$emit('input', this.value)
      this.$emit('change', this.value)
    }
  }
}
</script>
